import thoughtworks.test.InvalidNumberException;


public class Test {
	
	public static String convertNumberToRoman(int num) throws InvalidNumberException{
		StringBuilder text = new StringBuilder();
		if(num >0 && num < 3999){
			for(int i =0; i<13; i++){
				while(num >= ConstantsUtil.numbers[i]){
					num -= ConstantsUtil.numbers[i];
					text.append(ConstantsUtil.romanNo[i]);
				}
			}
		} else {
			throw new InvalidNumberException("INVALID NUMBER.");
		}
		return text.toString();
	}
	public static void main(String[] args) {
		try {
			System.out.println(convertNumberToRoman(5000));
		} catch (InvalidNumberException e) {
			System.out.println(e.getMessage());
		}
	}
}
